/**
 *  Document   : CustomerDAO
 *  Created on : 24 juil. 2008, 22:36:40
 *  Author     : Rivo
 */

package gla.centralhotel.dao;

import gla.centralhotel.dao.interfaces.ICustomerDAO;
import gla.centralhotel.model.Customer;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;


@Stateless
public class CustomerDAO implements ICustomerDAO {
    @PersistenceContext
    private EntityManager em;

    public void create(Customer customer) {
        em.persist(customer);
    }

    public void edit(Customer customer) {
        em.merge(customer);
    }

    public void remove(Customer customer) {
        em.remove(em.merge(customer));
    }

    public Customer find(Object id) {
        return em.find(gla.centralhotel.model.Customer.class, id);
    }

    public List<Customer> findAll() {
        return em.createQuery("select object(o) from Customer as o").getResultList();
    }
    
    

}
